#ifndef __NIGHTASSERTION_H__
#define __NIGHTASSERTION_H__

#include "NightDelegate.h"
#include "assert.h"


namespace NE
{

	enum ExceptionType
	{
		ERR_PARSE_XML,
		ERR_MAX
	};


	namespace Event
	{

		/** void onAssertionFailed(const char* _expr, const char* _desc, const char* _file, int _line, const char* _func); */
		extern SingleEvent5<void, const char*, const char*, const char*, int, const char*> eventAssertionFailed;

		/** void onExceptionOccurred(int _type, const char* _desc, const void* _data, const char* _func); */
		extern SingleEvent4<void, int, const char*, const void*, const char*> eventExceptionOccurred;

	}


#ifdef NE_DEBUG_ASSERT_MODE

#ifdef _DEBUG

#define NightAssert(expr) if (!(expr)) NE::Event::eventAssertionFailed.invoke(#expr, 0, __FILE__, __LINE__, __FUNCTION__)

#define NightAssertDescription(expr, desc) if (!(expr)) NE::Event::eventAssertionFailed.invoke(#expr, desc, __FILE__, __LINE__, __FUNCTION__)

#else

#define NightAssert(expr)

#define NightAssertDescription(expr, desc)

#endif // _DEBUG

#else

#define NightAssert(expr) if (!(expr)) NE::Event::eventAssertionFailed.invoke(#expr, 0, __FILE__, __LINE__, __FUNCTION__)

#define NightAssertDescription(expr, desc) if (!(expr)) NE::Event::eventAssertionFailed.invoke(#expr, desc, __FILE__, __LINE__, __FUNCTION__)

#endif // NE_DEBUG_ASSERT_MODE

#define NightAssertDebug(expr) assert(expr)

#define NightExcept(num, desc, ext) NE::Event::eventExceptionOccurred.invoke(num, desc, ext, __FUNCTION__)

}


#endif